// 司机管理 API
import request from '@/utils/request'
import type { ApiResponse, PageResult } from '@/types/api'
import type { Driver, DriverFormData } from '@/types/driver'

/**
 * 获取司机列表
 */
export function getDriverList(params: {
  current?: number
  size?: number
  driverStatus?: string
  keyword?: string
  siteId?: number  // 站点ID（租户管理员可指定，普通用户自动使用当前站点）
}) {
  return request<ApiResponse<PageResult<Driver>>>({
    url: '/tenant/driver/list',
    method: 'get',
    params,
  })
}

/**
 * 获取司机详情
 */
export function getDriverById(id: number) {
  return request<ApiResponse<Driver>>({
    url: `/tenant/driver/${id}`,
    method: 'get',
  })
}

/**
 * 创建司机
 */
export function createDriver(data: DriverFormData) {
  return request<ApiResponse<Driver>>({
    url: '/tenant/driver',
    method: 'post',
    data,
  })
}

/**
 * 更新司机
 */
export function updateDriver(id: number, data: DriverFormData) {
  return request<ApiResponse<null>>({
    url: `/tenant/driver/${id}`,
    method: 'put',
    data,
  })
}

/**
 * 删除司机
 */
export function deleteDriver(id: number) {
  return request<ApiResponse<null>>({
    url: `/tenant/driver/${id}`,
    method: 'delete',
  })
}

